﻿using Bll;
using Dal;
using Dtl;
using System;
using System.Data;
using System.Collections.Generic;

namespace Service
{
    class DMSServices : IDMSServices
    {
        /*****/
        #region Métodos del servicio de usuarios
        public int validateUser(string UserName, string Password)
        {
            return UserBlo.ValidateUser(UserName, Password);
        }

        public string getRols()
        {
            return UserBlo.getRols();
        }

        public int setUser(string idUser, string userName, string name, string pass, string mail, string skype, string msn, string phone, string phone2, int rol, string status, bool encriptar)
        {
            return UserBlo.SetUser(idUser, userName, name, pass, mail, skype, msn, phone, phone2, rol, status, encriptar);
        }

        public string getUserbyUserName(string userName)
        {
            return UserBlo.getUserbyUsername(userName).GetXml();
        }

        public string getUsers()
        {
            return UserBlo.getUsers().GetXml();
        }
        #endregion 

        #region Métodos del servicio de objetos
        public DataTable getMenuTabs()
        {
            return ObjectBlo.getMenuTabs();
        }

        public DataTable getMenuGroups()
        {
            return ObjectBlo.getMenuGroups();

        }
        public DataTable getMenuTools()
        {
            return ObjectBlo.getMenuTools();
        }
        public DataTable getEnvironments()
        {
            return ObjectBlo.getEnvironments();
        }
        #endregion

        #region Métodos del servicio de DMS
        public string getCCFOTReport(string ambient, string distributor, DateTime startDate, DateTime endDate)
        {
            DataSet ds = CCFOTBlo.getCCFOTReport(ambient, distributor, startDate, endDate);
            return ds == null ? null : Compression.Compress(ds.GetXml());
        }
        //--------------------------------------------------------------------------------------------------------
        //FAR
        public string getOInvoiceReport(string distributor, DateTime startDate, DateTime endDate, string ambient)
        {
            DataSet ds = OrderInvoiceBlo.getOInvoiceReport(distributor, startDate, endDate, ambient);
            return ds == null ? null : Compression.Compress(ds.GetXml());
        }
        //FAR       
        public string getOItemsInvoiceReport(string distributor, DateTime startDate, DateTime endDate, string ambient)
        {            
            DataSet ds =OrderItemsInvoiceBlo.getOrderItemsInvoiceReport(distributor, startDate, endDate, ambient);
            return ds == null ? null : Compression.Compress(ds.GetXml());
        }
        //FAR        
        public string getOItemsInvoiceByInvoiceReport(string distributor, DateTime startDate, DateTime endDate, string cdInvoice, string ambient)
        {
            DataSet ds = OrderItemsInvoiceBlo.getOItemsInvoiceByInvoiceReport(distributor, startDate, endDate, cdInvoice, ambient);
            return ds == null ? null : Compression.Compress(ds.GetXml());             
        }
        //FAR
        public string  getOrderInvoice_AUD_Report(string distributor, string opcionReport_OI, DateTime startDate, DateTime endDate, string ambient)
        {
            DataSet ds = OrderInvoiceBlo.getOrderInvoice_AUD_Report(distributor, opcionReport_OI, startDate, endDate, ambient);
            return ds == null ? null : Compression.Compress(ds.GetXml());                         
        }
        //FAR       
        public string  getSurtidosReport(string cdPais, string ambient)
        {
            DataSet ds = SurtidosBlo.getSurtidosReport(cdPais, ambient);
            return ds == null ? null : Compression.Compress(ds.GetXml());              
        }
        //--------------------------------------------------------------------------------------------------------
        //Eduardo:
        public string QuotaByDistributor(string ambient, string Distributor)
        {
            return QuotaBlo.getDistributorByQuota(ambient, Distributor).GetXml();

        }
        public string getStockReport(string distributor, DateTime startDate, DateTime endDate, string ambiente)
        {
            return StockBlo.getStockReport(distributor, startDate, endDate, ambiente).GetXml();
        }
        //Eduardo:
        public string StoreByDistributor(string ambient, string Distributor)
        {
            return StoreBlo.getDistributorByStore(ambient, Distributor).GetXml();
        }

        public string getVisitReport(string distributor, DateTime startDate, DateTime endDate, string ambiente)
        {
            return VisitBlo.getVisitReport(distributor, startDate, endDate, ambiente).GetXml();
        }
        public string getCabinetInventoryReport(string distributor, string ambiente)
        {
            return CabinetInventoryBlo.getCabinetInventoryReport(distributor, ambiente).GetXml();
        }
        public string getRegionUserReport(string ambient, string distributor)
        {
            return RegionUserDao.getRegionUserReport(ambient, distributor).GetXml();
        }
        public string getClassificationReport(string country, string ambiente)
        {
            return ClassificationDao.getClassificationReport(country, ambiente).GetXml(); ;
        }
        public string getDistributorsList(string ambient)
        {
            return Tools.getDistributorsList(ambient).GetXml();
        }

        public string getCountryList(string ambiente)
        {
            return Tools.getCountryList(ambiente).GetXml();
        }

        public string getCityReport(string ambient, string distributor)
        {
            return CityBlo.getCityReport(ambient, distributor).GetXml();
        }

        public string getProductReport(string ambient, string country)
        {
            return ProductBlo.getProductReport(ambient, country).GetXml();
        }

        public string getImportClass(string country, string ambiente)
        {
            return ImportClassificationBlo.getImportClassification(country, ambiente).GetXml();
        }
        public string getImportClassH(string country, string ambiente)
        {
            return ClassificationHierarchyBlo.getClassificationH(country, ambiente).GetXml();
        }
        public string getCurrency(string ambiente)
        {
            return CurrencyBlo.getCurrency(ambiente).GetXml(); ;
        }
        public string getRouteReport(string ambient, string distributor)
        {
            return RouteBlo.getRouteReport(ambient, distributor).GetXml();
        }
        public int setConversion(Dtl.Conversion conversion, string ambiente)
        {
            return ConversionBlo.setConversion(conversion, ambiente);
        }
        public int editConversion(Dtl.Conversion conversion, string ambiente)
        {
            return ConversionBlo.editConversion(conversion, ambiente);
        }
        public string getConversion(int idCurrencyTo, int idCurrencyFrom, short nrYear, string ambiente)
        {
            return ConversionBlo.getConversion(idCurrencyTo, idCurrencyFrom, nrYear, ambiente).GetXml();
        }
        public string listConversion(string ambiente)
        {
            return ConversionBlo.listConversion(ambiente).GetXml();
        }
        public int setUnit(Dtl.Unit unit, string ambiente)
        {
            return UnitBlo.setUnit(unit, ambiente);
        }

        public string getUnit(short idUnit, string ambiente)
        {
            return UnitBlo.getUnit(idUnit, ambiente).GetXml();
        }

        public string listUnit(string ambiente)
        {
            return UnitBlo.listUnit(ambiente).GetXml();
        }

        public int editUnit(Dtl.Unit unit, string ambiente)
        {
            return UnitBlo.editUnit(unit, ambiente);
        }

        public string getDistributorsFTPProgress(string ambient, string minRows)
        {
            return FTPBlo.getDistributorsFTPProgress(ambient, minRows).GetXml();
        }

        public string getTriStateFTPReport(string ambient, DateTime startDate, DateTime endDate)
        {
            return FTPBlo.getTriStateFTPReport(ambient, startDate, endDate).GetXml();
        }
        public string getDistributorsFTPActivity(string ambient, DateTime startDate, DateTime endDate, bool date)
        {
            return FTPBlo.getDistributorsFTPActivity(ambient, startDate, endDate, date).GetXml();
        }
        public string getDistributorsFTPStatus(string ambient)
        {
            return FTPBlo.getDistributorsFTPStatus(ambient).GetXml();
        }
        public string getUnileverFTPStatus(string ambient)
        {
            return FTPBlo.getUnileverFTPStatus(ambient).GetXml();
        }

        public bool SetTransactionUnit(List<Dtl.Unit> unit, string ambiente)
        {
            return UnitBlo.SetTransactionUnit(unit, ambiente);
        }
        public string QuotaUByDistributor(string ambient, string country)
        {
            return QuotaUBlo.getDistributorByQuotaU(ambient, country).GetXml();
        }

        public int deleteUnit(int idUnit, string ambiente)
        {
            return UnitBlo.deleteUnit(idUnit, ambiente);
        }

        public string getProductGold(string ambiente)
        {
            DataSet ds = productGoldBlo.getProductGold(ambiente);
            return ds == null ? null : ds.GetXml();
        }
        public string getTriStateFTPReportDetailed(string ambient, int idDistributor, DateTime startDate, DateTime endDate)
        {
            DataSet ds = FTPBlo.getTriStateFTPReportDetailed(ambient, idDistributor, startDate, endDate);
            return ds == null ? null : ds.GetXml();
        }

        public int setRoleGrant(Role role, List<Dtl.RoleGrant> RoleGrant)
        {
            return RoleGrantBlo.setRoleGrantt(role, RoleGrant);
        }
        public string getObjects()
        {
            DataSet ds = RoleGrantBlo.getObjects();
            return ds == null ? null : ds.GetXml();
        }

        public string getObjectsByRole(string cdRole) 
        {
            DataSet ds = RoleGrantBlo.getObjectsByRole(cdRole);
            return ds == null ? null : ds.GetXml();
        }

        public string getDistribuitorsListWhitCountries()
        {
            DataSet ds = Tools.getDistribuitorsListWhitCountries();
            return ds == null ? null : ds.GetXml();
        }

        public string getEmailsBydistributors(int idDistributor) 
        {
            DataSet ds = DistribuitorEmailBlo.getEmailsBydistributors(idDistributor);
            return ds == null ? null : ds.GetXml();
        }

        public string getPhaseBydistributors(int idDistributor) 
        {
            DataSet ds = DistribuitorEmailBlo.getPhaseBydistributors(idDistributor);
            return ds == null ? null : ds.GetXml();
        }

        public string getPhases() 
        {
            DataSet ds = DistribuitorEmailBlo.getPhases();
            return ds == null ? null : ds.GetXml();
        }

        public int setDistribuitorPhaseAndEmail(int idDistribuitor, bool sendAlert, List<Dtl.DistribuitorEmail> listEmail, List<Dtl.DistribuitorPhase> lisDistPhase) 
        {
            return DistribuitorEmailBlo.setDistribuitorPhaseAndEmail(idDistribuitor, sendAlert, listEmail, lisDistPhase);
        }

        public int DeleteEmail(int idDistribuitorEmail)
        {
            return DistribuitorEmailDAO.DeleteEmail(idDistribuitorEmail);
        }

        public int DeletePhase(int idDistrbuitorPhase)
        {
            return DistribuitorEmailDAO.DeletePhase(idDistrbuitorPhase);
        }

        public DataTable getMenu(string rol)
        {
            return ObjectBlo.getMenu(rol);
        }

        public string getEmailGroups()
        {
            DataSet ds = EmailGroupBlo.getEmailGroups();
            return ds == null ? null : ds.GetXml();            
           
        }

        public string getEmailGroupsItems(int idEmailGroup)
        {
            DataSet ds = EmailGroupBlo.getEmailGroupsItems(idEmailGroup);
            return ds == null ? null : ds.GetXml(); 
        }

        public int setEmailGroup(List<EmailGroup> listEmailGroup, List<EmailGroupItem> listEmailGroupItem)
        {
            return EmailGroupBlo.setEmailGroup(listEmailGroup, listEmailGroupItem);
        }

        public int DeleteEmailGroup(int idEmailGroup)
        {
            return EmailGroupBlo.DeleteEmailGroup(idEmailGroup);
        }

        public int DeleteEmailGroupItem(int idEmailGroup, int idDistributor)
        {
            return EmailGroupBlo.DeleteEmailGroupItem(idEmailGroup, idDistributor);
        }

        public string getPeriodSchedule()
        {
            DataSet ds = ScheduleBlo.getPeriodSchedule();
            return ds == null ? null : ds.GetXml();
        }

        public string getPeriodScheduleAlerts()
        {
            DataSet ds = ScheduleBlo.getPeriodScheduleAlerts();
            return ds == null ? null : ds.GetXml();
        }

        public int setScheduleAlerts(List<Schedule> listSchedule)
        {
            return ScheduleBlo.setScheduleAlerts(listSchedule); 
        }

        public int DeleteSchedule(int idSchedule)
        {
            return ScheduleBlo.DeleteSchedule(idSchedule);
        }

        #endregion

    }
}